<%@page import="com.spmanage.util.HttpUtil"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="com.spmanage.util.BillingUtil"%><%@page import="com.spmanage.util.DbOperation"%>
<%@page import="com.spmanage.util.SqlUtil"%><%@page import="com.spmanage.util.WebAction"%>
<%@page import="com.spmanage.util.StringUtil"%><%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%><%
	WebAction webAction = new WebAction(request,response);
    
	System.out.println("广东高谷-IVR挂断参数："+request.getQueryString());
    
    String mobile = webAction.getParameterString("ani");		//用户手机号
    String myChannel = webAction.getParameterString("channel");	//空中传的渠道号
    String carrier = webAction.getParameterString("carrier");	//运营商
    String callno = webAction.getParameterString("dnis");		//拨打号码
    int fee = webAction.getParameterInt("fee");					//资费
    String calltime = webAction.getParameterString("stime");	//拨打时间
    String halttime = webAction.getParameterString("etime");	//挂断时间
    int feeseconds = webAction.getParameterInt("seclen");	//拨打时长
    String provinceName = webAction.getParameterString("province");	//省份
    
    
    System.out.println("广东高谷-IVR挂断参数资费："+fee);
    
    StringBuilder getChannelIdSql = new StringBuilder("select cpid from adminspcp where spcommand = '");
    getChannelIdSql.append(callno);
    getChannelIdSql.append("'");
    int channel =SqlUtil.getIntResult(getChannelIdSql.toString(),5) ;
    int ischeck = BillingUtil.getIvrCheckCall(channel);
    
    int provinceId = BillingUtil.getProvinceId(mobile);
    
    String spId="";//spid：30,后期还能会变成动态的
   	if(callno.equals("1259025217")){
   		spId="30";
   	}
   	else if(callno.equals("1259025212")){
   		spId="131";
   	}
   	else if(callno.equals("1259025372")){
   		spId="132";
   	}
	//1259025212，1259025372
    //------------------------------------------------------
    if(ischeck==0){//0为不扣量，1为扣量
		//合作方url
		String url="";
		if(callno.equals("1259025217")||callno.equals("1259025212")){
			//channel="10063";
			url="http://las.energysh.com.cn/las2/logs.htm";
			url=url+"?ani="+mobile+"&dnis="+callno+"&stime="+URLEncoder.encode(calltime,"UTF-8")+"&etime="+URLEncoder.encode(halttime,"UTF-8")+"&seclen="+feeseconds+"&fee="+fee;;
			System.out.println("高谷-艾麒-IVR同步:"+url);
			HttpUtil.getHtmlSource(url,"UTF-8");
		}
	
		//-------------------------------------------------------
    }
	//保存到ivr天表
    StringBuilder conditionSql = new StringBuilder();
    conditionSql.append("'");
    conditionSql.append(spId);
    conditionSql.append("','");
    conditionSql.append(channel);//渠道号,后期还能会变成动态的
    conditionSql.append("','");
    conditionSql.append(provinceId);//省份ID
    conditionSql.append("','");
    conditionSql.append(mobile);//手机号
    conditionSql.append("','");
    conditionSql.append(callno);
    conditionSql.append("','");
    conditionSql.append(fee);
    conditionSql.append("','");
    conditionSql.append(carrier);
    conditionSql.append("','");
    conditionSql.append(calltime);
    conditionSql.append("','");
    conditionSql.append(halttime);
    conditionSql.append("','");
    conditionSql.append(feeseconds);
    conditionSql.append("','");
    conditionSql.append(ischeck);
    conditionSql.append("',");
    conditionSql.append("getDate()");
    System.out.println(conditionSql.toString());
    SqlUtil.executeUpdate("insert into  "+BillingUtil.getIvrHaltDay()+"(areaid,channel,province,mobile,callno,fee,carrier,calltime,halttime,feeseconds,ischeck,createdtime) values("+conditionSql.toString()+")",DbOperation.DB_STAT);

%><%="ok" %>
